/*
* @Author: xfy
* @Date:   2017-08-26 18:54:29
* @Last Modified by:   xfy
* @Last Modified time: 2017-08-29 15:23:18
*/
'use strict';
var _supper = require('util/supper.js');
var _user = {
    //用户登录
    login : function(userInfo, resolve, reject){
        _supper.request({
            url     : _supper.getServerUrl('/usr/login.do'),
            data    : userInfo,
            method  : 'POST',
            success : resolve,
            error   : reject
        });
    },
    //检查用户名
    checkUsername : function(username, resolve, reject){
        _supper.request({
            url     : _supper.getServerUrl('/usr/checkUsername.do'),
            data    : {
                username : username
            },
            method  : 'POST',
            success : resolve,
            error   : reject
        });
    },
    //用户注册
    register : function(userInfo, resolve, reject){
        _supper.request({
            url     : _supper.getServerUrl('/usr/register.do'),
            data    : userInfo,
            method  : 'POST',
            success : resolve,
            error   : reject
        });
    },
    //检查登录状态
    checkLogin : function(resolve, reject){
        _supper.request({
            url     : _supper.getServerUrl('/usr/getPersonalInfo.do'),
            method  : 'POST',
            success : resolve,
            error   : reject
        });
    },
    //获取用户密码的提示问题
    getQuestion : function(username, resolve, reject){
        _supper.request({
            url     : _supper.getServerUrl('/usr/selectQuestion.do'),
            data    : {
                username : username
            },
            method  : 'POST',
            success : resolve,
            error   : reject
        });
    },
    //检查密码提示问题答案
    checkAnswer : function(userInfo, resolve, reject){
        _supper.request({
            url     : _supper.getServerUrl('/usr/forgetCheckAnswer.do'),
            data    : userInfo,
            method  : 'POST',
            success : resolve,
            error   : reject
        });       
    },
    //重置密码
    resetPassword : function(userInfo, resolve, reject){
        _supper.request({
            url     : _supper.getServerUrl('/usr/forgetResetPassword.do'),
            data    : userInfo,
            method  : 'POST',
            success : resolve,
            error   : reject
        });
    },
    //获取用户信息
    getUserInfo : function(resolve, reject){
        _supper.request({
            url     : _supper.getServerUrl('/usr/getPersonalInfo.do'),
            method  : 'POST',
            success : resolve,
            error   : reject
        });
    },
    //更新个人信息
    updateUserInfo : function(userInfo, resolve, reject){
        _supper.request({
            url     : _supper.getServerUrl('/usr/save.do'),
            data    : userInfo,
            method  : 'POST',
            success : resolve,
            error   : reject
        });
    },
    //登录状态下更新密码
    updatePassword : function(userInfo, resolve, reject){
        _supper.request({
            url     : _supper.getServerUrl('/usr/updatePassword.do'),
            data    : userInfo,
            method  : 'POST',
            success : resolve,
            error   : reject
        });
    },
    //退出登录
    logout : function(resolve, reject){
        _supper.request({
            url     : _supper.getServerUrl('/usr/logout.do'),
            method  : 'POST',
            success : resolve,
            error   : reject
        });
    }
}
module.exports = _user;